package com.chixing.service.impl;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.chixing.commons.ServerResponse;
import com.chixing.mapper.FlowMapper;
import com.chixing.pojo.Flow;
import com.chixing.service.IFlowService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author xiaotao
 * @since 2022-10-19
 */
@Service
public class FlowServiceImpl implements IFlowService {
    @Autowired
    private FlowMapper flowMapper;
    @Override
    public ServerResponse save(Flow flow) {
        int rows = flowMapper.insert(flow);
        if(rows>0)
            return ServerResponse.success("添加流水成功",true);
        else
            return ServerResponse.fail("添加流水失败",false);
    }

    @Override
    public ServerResponse getFlow(String traceNo) {
        QueryWrapper<Flow> wrapper = new QueryWrapper<>();
        wrapper.eq("flow_id",traceNo);
        Flow flow = flowMapper.selectOne(wrapper);
        if(flow!=null)
            return ServerResponse.success("查询流水成功",flow);
        else
            return ServerResponse.fail("查询流水失败",null);
    }
}
